{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "96132a23",
   "metadata": {},
   "source": [
    "  ###  注释的目的：\n",
    "        1、代码的提示（笔记）\n",
    "         2、不运行的代码\n",
    "      import random\n",
    "      wait_time = random.randint(1,60)\n",
    "      print(wait_time)\n",
    "       word = \"bottles\"\n",
    "      print(words)\n",
    "      知识点_用户输入\n",
    "       用户输入\n",
    " "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ec42afcb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入正确的账号：yuanlin\n",
      "请输入正确的密码：456789\n"
     ]
    }
   ],
   "source": [
    "username = input(\"请输入正确的账号：\")\n",
    "password = input(\"请输入正确的密码：\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "29ea87c8",
   "metadata": {},
   "source": [
    "### 基础登陆系统"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ceb02c23",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'user_data' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\Users\\杜源霖~1\\AppData\\Local\\Temp/ipykernel_34872/4239587431.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0musername\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0muser_data\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mpassword\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0muser_password\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"登陆成功，欢迎\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0musername\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"使用~\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"您的账号或密码不正确\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'user_data' is not defined"
     ]
    }
   ],
   "source": [
    "if username == user_data:\n",
    "    if password == user_password:\n",
    "        print(\"登陆成功，欢迎\",username,\"使用~\")\n",
    "    else:\n",
    "        print(\"您的账号或密码不正确\")\n",
    "else:\n",
    "    print(\"您的账号或密码不正确\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb18a1b9",
   "metadata": {},
   "source": [
    "  ###  while True 设置条件，可终止循环\n",
    "### while True 可实现for + range的功能"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9d03d4d5",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (Temp/ipykernel_34872/3329315070.py, line 5)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\杜源霖~1\\AppData\\Local\\Temp/ipykernel_34872/3329315070.py\"\u001b[1;36m, line \u001b[1;32m5\u001b[0m\n\u001b[1;33m    if count == 100\u001b[0m\n\u001b[1;37m                   ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "cont = 0\n",
    "while True:\n",
    "    count = count + 1\n",
    "    print(\"爱丽丝儿\")\n",
    "    if count == 100\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e25db4b",
   "metadata": {},
   "source": [
    "### copy()很重要 思考，赋值是真正的复制么？赋值（=） <=> copy? ----不等价的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c432bff9",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'stu_id' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\Users\\杜源霖~1\\AppData\\Local\\Temp/ipykernel_34872/2151695299.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mstu_id_matedata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mstu_id\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"stu_id\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;31m# 实验2 copy()\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[0mstu_id_matedata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mstu_id\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mstu_id\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'stu_id' is not defined"
     ]
    }
   ],
   "source": [
    "stu_id_matedata = stu_id\n",
    "print(\"stu_id\",)\n",
    "# 实验2 copy()\n",
    "stu_id_matedata = stu_id.copy()\n",
    "stu_id.pop(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef673b3e",
   "metadata": {},
   "source": [
    "##  实验3 切片实现复制 \n",
    "## 总结：赋值并非正在意义上的复制\n",
    "## 思考，如何让取出所有位置的10001的index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "56bfda60",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'stu_id' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\Users\\杜源霖~1\\AppData\\Local\\Temp/ipykernel_34872/960292658.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mstu_id\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[1;31m# 循环遍历stu_id的所有内容\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mi\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m10001\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m         \u001b[1;31m# 判断如果元素为10001的时候，怎么取出索引呢？\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstu_id\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'stu_id' is not defined"
     ]
    }
   ],
   "source": [
    "for i in stu_id:\n",
    "    # 循环遍历stu_id的所有内容\n",
    "    if i == 10001:\n",
    "        # 判断如果元素为10001的时候，怎么取出索引呢？\n",
    "        print(stu_id.index(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "98189235",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'stu_id' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\Users\\杜源霖~1\\AppData\\Local\\Temp/ipykernel_34872/3952474949.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mpop_values_list\u001b[0m \u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mitem\u001b[0m \u001b[1;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstu_id\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m     \u001b[1;31m# print(index,item)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mitem\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m10001\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mitem\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'stu_id' is not defined"
     ]
    }
   ],
   "source": [
    "pop_values_list =[]\n",
    "for index,item in enumerate(stu_id):\n",
    "    # print(index,item)\n",
    "    if item == 10001:\n",
    "        print(index,item)\n",
    "        pop_values_list.append(index)\n",
    "print(\"我们想要删除的pop()的值:\",pop_values_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a7506b6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
